import axios from "./axios";

//轮播图  https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata

export const swiperdataApi=()=>{
    return axios({
        method:'GET',
        url:'https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata',
    })
}

//导航菜单  https://api-hmugo-web.itheima.net/api/public/v1/home/catitems

export const catitemsApi=()=>{
    return axios({
        method:'GET',
        url:'https://api-hmugo-web.itheima.net/api/public/v1/home/catitems',
    })
}

//楼层  https://api-hmugo-web.itheima.net/api/public/v1/home/floordata

export const floordataApi=()=>{
    return axios({
        method:'GET',
        url:'https://api-hmugo-web.itheima.net/api/public/v1/home/floordata',
    })
}

//搜索 https://api-hmugo-web.itheima.net/api/public/v1/goods/qsearch

export const qsearchApi=(query)=>{
    return axios({
        method:'GET',
        url:'https://api-hmugo-web.itheima.net/api/public/v1/goods/qsearch',
        params:{
            query
        }
    })
}
//商品详情 https://api-hmugo-web.itheima.net/api/public/v1/goods/detail

export const detailApi=(goods_id)=>{
    return axios({
        method:'GET',
        url:'https://api-hmugo-web.itheima.net/api/public/v1/goods/detail',
        params:{
            goods_id
        }
    })
}

//商品分类  https://api-hmugo-web.itheima.net/api/public/v1/categories

export const categoriesApi=()=>{
    return axios({
        method:'GET',
        url:'https://api-hmugo-web.itheima.net/api/public/v1/categories',
    })
}

// 商品列表  https://api-hmugo-web.itheima.net/api/public/v1/goods/search

export const searchApi=(query)=>{
    return axios({
        method:'GET',
        url:'https://api-hmugo-web.itheima.net/api/public/v1/goods/search',
        params:{
            query
        }
    })
}

// 注册  http://localhost:12345/api/user/register

export const registerApi=(username,password)=>{
    return axios({
        method:'POST',
        url:'http://localhost:12345/api/user/register',
        data:{
           username,password
        }
    })
}

// 登录  http://localhost:12345/api/user/login

export const loginApi=(username,password)=>{
    return axios({
        method:'POST',
        url:'http://localhost:12345/api/user/login',
        data:{
           username,password
        }
    })
}

// 订单  http://localhost:12345/api/order/create

export const createApi=(data)=>{
    return axios({
        method:'POST',
        url:' http://localhost:12345/api/order/create',
        data:{
          ...data
        }
    })
}

// 订单详情  http://localhost:12345/api/order/getOrder/ak0jbjczik

export const getOrderApi=(orderId)=>{
    return axios({
        method:'GET',
        url:'http://localhost:12345/api/order/getOrder/'+orderId,
        data:{
          orderId
        }
    })
}


// 支付  http://localhost:12345/api/order/pay

export const payApi=(data)=>{
    return axios({
        method:'POST',
        url:'http://localhost:12345/api/order/pay',
        data:{
          ...data
        }
    })
}

// 订单详情  http://localhost:12345/api/order/getOrderList/zhangsan

export const getOrderListApi=(username)=>{
    return axios({
        method:'GET',
        url:' http://localhost:12345/api/order/getOrderList/'+username,
        data:{
          username
        }
    })
}



